<style type="text/css">
    /*#danhsach{ 
        width: 900px; height: 500px; padding-top: 10px;
        background: gray; overflow: scroll;
    }*/
    table{border-collapse:collapse; margin: 0 auto;}
    td{ border: 1px solid #000; padding: 5px;}
	th{ border: 1px solid #000}
	.tieude {width: 120px; text-align: center; color: #fff;}
	.nd {width: 120px; text-align: center; color: #000;}
    .ch{width: 40px; text-align: center; color: #fff;}
</style>

<div id="function">
    HIỆU CHỈNH ĐĂNG KÝ MÔN HỌC
</div>


<div id="function_content" style="float: left;">

       <?php 
	   		@include "../../app/connection.php";
			$namhoc = mysql_query("SELECT HOCKY, NAM FROM dangky GROUP BY HOCKY, NAM ORDER BY NAM DESC, HOCKY DESC LIMIT 1");
			$row = mysql_fetch_row($namhoc);
			$str = "SELECT MAMONHOC,MALOP, count(DISTINCT MSSV) FROM dangky WHERE HOCKY='$row[0]' AND NAM='$row[1]' GROUP BY MAMONHOC,MALOP";
			$r = mysql_query($str);
			echo "<table border='1'>";
			echo "<tr style='background: #247CB9;'><th class='tieude'>Mã lớp môn học</th><th class='tieude'>Số lượng đã đăng ký</th><th class='tieude'></th></tr>";
			while($rw = mysql_fetch_array($r))
			{
				//echo "<tr> Lop: ".$rw[0].".".$rw[1]. "   So luong: ".$rw[2]."";
				echo "<tr><td class='nd'>".$rw[0].".".$rw[1]."</td><td class='nd'>".$rw[2]."</td><td class='ch'><input type='checkbox' name='checks' value='".$rw[0].".".$rw[1].",".$row[0].",".$row[1]."' /></td></tr>";
			}
			echo "</table>";
	   ?>
        
</div>
 <input type="button" value="Xóa" name="xoa" style="float:left; width:80px;" />
<script language="javascript">
	$(document).ready(function(e) {
        $("input:checkbox[name='checks']").click(function(e) {
            if($(this).attr('checked'))
				$(this).attr('checked',false);
			else 
				$(this).attr('checked',true);
        });
    });

	$(document).ready(function(e) {
        $("input[name='xoa']").click(function(e) {
			var x = "";
			$("input:checkbox[name='checks']:checked").each(function(index, element) {
                alert($(this).val());
				//x.push($(this).val()+";");
				x += $(this).val()+";";
            });
			//alert(x);
            $.ajax({
				url: "dangkymh/huylop.php",
				type:"POST",
				data:"giatri="+x,
				success: function(text)
				{
					alert(text);
					window.location = "index.php?page=dkmh&function=dieukhien";
				}
				});
        });
    });
</script>